package com.bkaka.util.code;

import org.springframework.stereotype.Service;

import java.util.Random;

/**
 * Created by maxiaoqiang on 2018/7/26.
 */
@Service
public class CodeUtilServiceImpl implements CodeUtilService {

    @Override
    public String createCode(int length) {
        String code = "";
        Random rand = new Random();//生成随机数
        for (int i = 0; i < length; i++) {
            code += rand.nextInt(10);//生成6位验证码
        }
        return code;
    }
}
